/* add.t   ADDRESS MASTER DELETE TRIGGER                              */
/*Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                 */
/*All rights reserved worldwide.  This is an unpublished work.        */
/*V8:ConvertMode=NoConvert*/
/**********************************************************************/
/*  Program :add.t                                                    */
/*  Author  :Ben Holmes                                               */
/*  Date    :12/4/95                                                  */
/*  !Description : ad_mstr DELETE trigger                             */
/*          : In order to enhance this trigger to support additional  */
/*          : interfaces, add a DO-END block similar to the one       */
/*          : used for the Warehousing Interface to (1) check for the */
/*          : need to continue processing; (2) move the relevant      */
/*          : fields to an appropriate work area; and (3) call        */
/*          : one or more subprograms to continue processing.         */
/*          : This .t program should remain short, relying on         */
/*          : subprograms to perform most of the work.                */
/**********************************************************************/
/*                             MODIFY LOG                             */
/**********************************************************************/
/*Revision 8.5          Last Modified:  12/04/95 BY: BHolmes *J0FY*   */
/*Revision 8.5          Last Modified:  07/27/96 BY: fwy     *J12B*   */
/*Revision 8.5          Last Modified:  08/16/96 BY: deg     *J145*   */
/*Revision 9.1          Last Modified:  08/11/00 BY: *N0KK* jyn       */
/*                                                                    */
/*                                                                    */
/**********************************************************************/

TRIGGER PROCEDURE FOR DELETE OF AD_MSTR.

/*J12B  if not can-find(first whl_mstr where whl_mstr.whl_act no-lock) */
/*J12B  then leave. */

        {mfdeclre.i }
        define new shared work-table wf_old_ad_mstr like ad_mstr.
        define new shared variable w-recid as recid.
        define variable w-file as character format "x(24)".

/*J145*
 *      /* Warehousing Interface processing */
 *
 *      WI:
 *      do:
 *
 *      /* If there is no active external warehouse that is flagged to
 *      receive customer or supplier export transactions, then do not process */
 * /*J12B*/    if not can-find(first whl_mstr no-lock
 * /*J12B*/        where whl_mstr.whl_act
 * /*J12B*/          and (whl_mstr.whl_cust_exp or whl_mstr.whl_sup_exp))
 * /*J12B*/    then leave WI.
 *
 *      /* Move key ad_mstr values to work table for subsequent processing */
 *          assign w-recid = recid(ad_mstr).
 *          create wf_old_ad_mstr.
 *          if recid(wf_old_ad_mstr)= -1 then .
 *          assign
 *              wf_old_ad_mstr.ad_addr      = ad_mstr.ad_addr
 *              wf_old_ad_mstr.ad_type      = ad_mstr.ad_type
 *          .
 *
 *      /* Call subprogram to create export transactions for warehouses */
 *          w-file = "wiadd.p".
 *          {gprun.i ""wiadd.p""}
 *
 * /*J12B*/end. /* WI */
 *J145*/

	HK:
	do:
        if not can-find ( first dt_mstr where dt_table = "ad_mstr" and dt_type = "DEL" ) then leave HK.
        
        if not can-find ( first wf_old_ad_mstr ) then do:
            create wf_old_ad_mstr.
            if recid(wf_old_ad_mstr)= -1 then .
        end.
        
        buffer-copy ad_mstr to wf_old_ad_mstr no-error.

        for first dt_mstr no-lock where dt_table = "ad_mstr" and dt_type = "DEL" :
        
			run value(global_user_lang_dir + "hk/hktrigdel.p")
       			"wf_old_ad_mstr"		/*old buffer*/
       			""						/*new buffer*/
       			dt_table				/*table name*/
       			""						/*field name*/
       			dt_type					/*type*/
       			recid(ad_mstr)			/*key*/	
       			ad_mstr.ad_addr			/*key1*/
				""						/*key2*/
       			""						/*key3*/
       			""						/*key4*/
       			""						/*key5*/
       			""						/*key6*/
       			""						/*key7*/
       			""						/*key8*/
       			.
			
        end.
	end.
